package com.drguo.higouguo.service.impl;

import java.util.Date;
import java.util.List;

import com.drguo.higouguo.dao.OrderDao;
import com.drguo.higouguo.dao.OrderDetailDao;
import com.drguo.higouguo.entity.Order;
import com.drguo.higouguo.entity.OrderDetail;
import com.drguo.higouguo.service.OrderService;
import com.drguo.higouguo.utils.GuoUtil;

public class OrderServiceImpl implements OrderService {
	private OrderDao orderDao;
	private OrderDetailDao orderDetailDao;
	//增加订单
	@Override
	public void addOrder(Order order, List<OrderDetail> orderDetails) {
		order.setId(GuoUtil.getId());
		order.setOrderTime(new Date());
		order.setStatus("1");//1未付款2已付款3未发货4已发货5已完成
		orderDao.addOrder(order);
		
		for(OrderDetail orderDetail : orderDetails){
			orderDetail.setId(GuoUtil.getId());
			orderDetail.setOrderId(order.getId());
			orderDetailDao.addOrderDetail(orderDetail);
		}
	}
	//后台订单列表
	@Override
	public List<Order> getOrders() {
		
		return orderDao.getOrders();
	}
	@Override
	public Order getOrderById(String id) {
		
		return orderDao.getOrderById(id);
	}

	public OrderDao getOrderDao() {
		return orderDao;
	}

	public void setOrderDao(OrderDao orderDao) {
		this.orderDao = orderDao;
	}

	public OrderDetailDao getOrderDetailDao() {
		return orderDetailDao;
	}

	public void setOrderDetailDao(OrderDetailDao orderDetailDao) {
		this.orderDetailDao = orderDetailDao;
	}


}
